package logic

import (
	"errors"
	"gorm.io/gorm"
	"web_app/dao/mysql"
	"web_app/modules"
)

func GetCommunityList() *[]modules.Community {
	var coms []modules.Community

	//查找到所有的community 并返回
	err := mysql.GetCommunityList(&coms)
	if errors.Is(err, gorm.ErrRecordNotFound) {
		coms = nil

	}
	return &coms
}

func GetCommunityDetail(communityID int64) *modules.Community {
	var com modules.Community
	err := mysql.GetCommunityById(&com, communityID)
	if errors.Is(err, gorm.ErrRecordNotFound) {
		return nil
	}

	return &com
}
